{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 鲜易网客户特征识别数据分析-数据分析报告\n",
    "------\n",
    "1.引入问题\n",
    "* 背景介绍\n",
    "* 提出问题\n",
    "\n",
    "2.研究方法\n",
    "* 订单分析\n",
    "* 客户匹配（找出无价值客户）\n",
    "\n",
    "3.研究结论\n",
    "* 研究结论\n",
    "* 相关建议"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 引入问题\n",
    "## 背景介绍\n",
    "### 电商平台\n",
    "* 平台概况：鲜易网是肉禽水产生鲜食材采购批发平台,面向B2B连锁餐饮企业、酒店提供肉禽批发,水产品批发,酒店食材,餐饮食材,酒店原材料等特色食材采购批发服务\n",
    "* 主营商品：果蔬、肉蛋、水产、粮油、水饮、零食等\n",
    "* 主要特色：半成品配送，环保方便；社区自提柜，产销联合\n",
    "* 服务区域：郑州市、开封市、安阳市等\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 提出问题\n",
    "* 优惠促销商品利润微薄，是企业用以发展新客户的营销手段\n",
    "* 有一类客户基本只购买优惠促销商品，很少购买正价商品，这类客户对企业没有价值，只会增加营销成本\n",
    "* 企业想要将无价值客户识别出来，同正常客户做区分，以便针对性的改变营销策略"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 问题：和正常客户相比，无价值客户有什么特征？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "\n",
    "plt.style.use('seaborn')\n",
    "plt.rcParams['font.family'] = ['Arial Unicode MS', 'Microsoft Yahei', 'SimHei', 'sans-serif']\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OrderedDict([('订单信息',          订单ID    客户ID  订单状态  优惠类型\n",
       "              0       47739    5245     1     0\n",
       "              1      341269    5245     0     0\n",
       "              2       32690    5254     1     0\n",
       "              3       45641    5254     1     0\n",
       "              4       66116    5254     1     0\n",
       "              5       79014    5254     1     0\n",
       "              6       79058    5254     0     0\n",
       "              7       79221    5254     1     0\n",
       "              8       79608    5254     1     0\n",
       "              9      146455    5254     1     0\n",
       "              10     148275    5254     1     0\n",
       "              11     149066    5254     1     1\n",
       "              12     240219    5286     1     1\n",
       "              13     287500    5286     1     0\n",
       "              14     287502    5286     0     0\n",
       "              15     290370    5286     0     0\n",
       "              16     290372    5286     0     0\n",
       "              17     378615    5286     0     0\n",
       "              18     378618    5286     0     0\n",
       "              19     378621    5286     0     0\n",
       "              20      66457    5292     1     0\n",
       "              21     211972    5292     0     1\n",
       "              22     226715    5292     1     0\n",
       "              23     237862    5292     0     1\n",
       "              24     246600    5292     1     0\n",
       "              25     248991    5292     0     1\n",
       "              26     249847    5292     1     1\n",
       "              27     256960    5292     1     1\n",
       "              28     422975    5292     1     0\n",
       "              29     148707    5474     1     0\n",
       "              ...       ...     ...   ...   ...\n",
       "              29120  445946  169197     0     1\n",
       "              29121  442081  169217     1     1\n",
       "              29122  442299  169269     1     1\n",
       "              29123  442333  169276     1     1\n",
       "              29124  442649  169299     0     1\n",
       "              29125  442726  169299     1     1\n",
       "              29126  443197  169318     1     1\n",
       "              29127  444034  169318     1     1\n",
       "              29128  443767  169393     0     1\n",
       "              29129  443770  169393     1     0\n",
       "              29130  443771  169393     1     0\n",
       "              29131  444237  169393     1     0\n",
       "              29132  443940  169445     0     1\n",
       "              29133  444077  169445     1     0\n",
       "              29134  445037  169445     0     0\n",
       "              29135  444721  169598     1     0\n",
       "              29136  445432  169598     0     1\n",
       "              29137  445444  169598     1     1\n",
       "              29138  444984  169613     1     1\n",
       "              29139  445427  169614     1     1\n",
       "              29140  445249  169691     1     1\n",
       "              29141  445279  169699     1     0\n",
       "              29142  447620  169699     1     1\n",
       "              29143  445884  169815     1     1\n",
       "              29144  447102  169832     1     1\n",
       "              29145  446758  169934     1     1\n",
       "              29146  446759  169934     1     0\n",
       "              29147  447165  169976     0     1\n",
       "              29148  447274  169976     0     1\n",
       "              29149  447375  169976     1     1\n",
       "              \n",
       "              [29150 rows x 4 columns]),\n",
       "             ('货物信息',         订单ID    货物ID      货物名称 优惠额度\n",
       "              0     264971  103247  自然乐园水果礼盒  >15\n",
       "              1     264994  103247  自然乐园水果礼盒  >15\n",
       "              2     266829  103247  自然乐园水果礼盒  >15\n",
       "              3     267232  103247  自然乐园水果礼盒  >15\n",
       "              4     269051  103247  自然乐园水果礼盒  >15\n",
       "              5     256809  101645       紫甘蓝  >15\n",
       "              6     256984  101645       紫甘蓝  >15\n",
       "              7     258700  101645       紫甘蓝  >15\n",
       "              8     268496  101645       紫甘蓝  >15\n",
       "              9     268510  101645       紫甘蓝  >15\n",
       "              10    275809  101645       紫甘蓝  >15\n",
       "              11    277573  101645       紫甘蓝  >15\n",
       "              12    284473  101645       紫甘蓝  >15\n",
       "              13    287662  101645       紫甘蓝  >15\n",
       "              14    287668  101645       紫甘蓝  >15\n",
       "              15    289079  101645       紫甘蓝  >15\n",
       "              16    290400  101645       紫甘蓝  >15\n",
       "              17    264515  103306        滋久  >15\n",
       "              18    266465  103306        滋久  >15\n",
       "              19    266994  103306        滋久  >15\n",
       "              20    272357  103306        滋久  >15\n",
       "              21    277529  103306        滋久  >15\n",
       "              22    258249  103305        滋久  >15\n",
       "              23    260035  103305        滋久  >15\n",
       "              24    263743  103305        滋久  >15\n",
       "              25    268881  103305        滋久  >15\n",
       "              26    271752  104052    猪蹄(一只)  >15\n",
       "              27    274915  104052    猪蹄(一只)  >15\n",
       "              28    276892  104052    猪蹄(一只)  >15\n",
       "              29    277573  104052    猪蹄(一只)  >15\n",
       "              ...      ...     ...       ...  ...\n",
       "              3100  284553  102103      冷冻鲜肉    0\n",
       "              3101  284927  102103      冷冻鲜肉    0\n",
       "              3102  285226  102103      冷冻鲜肉    0\n",
       "              3103  285307  102103      冷冻鲜肉    0\n",
       "              3104  285552  102103      冷冻鲜肉    0\n",
       "              3105  286058  102103      冷冻鲜肉    0\n",
       "              3106  286168  102103      冷冻鲜肉    0\n",
       "              3107  286815  102103      冷冻鲜肉    0\n",
       "              3108  287216  102103      冷冻鲜肉    0\n",
       "              3109  287519  102103      冷冻鲜肉    0\n",
       "              3110  291209  102103      冷冻鲜肉    0\n",
       "              3111  291234  102103      冷冻鲜肉    0\n",
       "              3112  291584  102103      冷冻鲜肉    0\n",
       "              3113  292142  102103      冷冻鲜肉    0\n",
       "              3114  284006  104323        牙签    0\n",
       "              3115  263864  103376   500元充值卡    0\n",
       "              3116  268178  103376   500元充值卡    0\n",
       "              3117  268277  103376   500元充值卡    0\n",
       "              3118  285796  103376   500元充值卡    0\n",
       "              3119  286098  103376   500元充值卡    0\n",
       "              3120  257077  103376   500元充值卡    0\n",
       "              3121  261240  103376   500元充值卡    0\n",
       "              3122  265594  103376   500元充值卡    0\n",
       "              3123  265982  103376   500元充值卡    0\n",
       "              3124  266432  103376   500元充值卡    0\n",
       "              3125  282903  103376   500元充值卡    0\n",
       "              3126  283994  103376   500元充值卡    0\n",
       "              3127  284171  103376   500元充值卡    0\n",
       "              3128  256095  103376   500元充值卡    0\n",
       "              3129  256499  103376   500元充值卡    0\n",
       "              \n",
       "              [3130 rows x 4 columns]),\n",
       "             ('顾客信息',\n",
       "                      客户ID   登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)    经验值  订单数\n",
       "              0       5245     55          1430413266            1495339734    206    1\n",
       "              1       5254     69          1430413266            1499041945    428   13\n",
       "              2       5286     57          1430413266            1509936376    280    1\n",
       "              3       5292    184          1430413266            1510135868    643    5\n",
       "              4       5474     71          1430413266            1481185064     61    2\n",
       "              5       5544    520          1430413266            1511065463   5033  103\n",
       "              6       5547     30          1430413266            1510577047    477    8\n",
       "              7       5552   2699          1430413266            1511245956  12673  164\n",
       "              8       5560     39          1430413266            1481811865     27    0\n",
       "              9       5580    137          1430413266            1506301413    236    2\n",
       "              10      5625    463          1430413266            1510935255   2087   14\n",
       "              11      5628    356          1430413266            1511145498  11494  166\n",
       "              12      5661  11675          1430413266            1511224143  34701  487\n",
       "              13      5690   1769          1430413266            1511175196  13398  182\n",
       "              14      5699    634          1430413266            1510274405   8415  121\n",
       "              15      5701     94          1430413266            1481201883    512    8\n",
       "              16      5723     29          1430413266            1488960790    163    2\n",
       "              17      5725   1372          1430413266            1510625605   9243  126\n",
       "              18      5726   1576          1430413266            1511162452  13078  193\n",
       "              19      5727    102          1430413266            1510223946   2574   37\n",
       "              20      5728    164          1430413266            1498397004    863   16\n",
       "              21      5734   1193          1430413266            1511169496   6852   86\n",
       "              22      5740    826          1430413266            1506164574   2309   19\n",
       "              23      5767     80          1430413266            1506216500   1681   17\n",
       "              24      5785     62          1430413266            1506783217    249    5\n",
       "              25      5789    170          1430413266            1511140849   1373   20\n",
       "              26      5804    730          1430413266            1511190699   2851   28\n",
       "              27      5816    374          1430413266            1508748129   1225   15\n",
       "              28      5880    206          1430413266            1511146306   3913   70\n",
       "              29      5912    288          1430413266            1510033445   1755   26\n",
       "              ...      ...    ...                 ...                   ...    ...  ...\n",
       "              2970  168758     18          1510124356            1510960789    105    2\n",
       "              2971  168792     15          1510136872            1510661772     60    1\n",
       "              2972  168831     78          1510182960            1511241351    635   10\n",
       "              2973  168834     12          1510187047            1511239077    102    3\n",
       "              2974  168948      6          1510233924            1510234362     48    1\n",
       "              2975  168976      7          1510275950            1511166273     66    3\n",
       "              2976  168981     30          1510278673            1511184888    146    2\n",
       "              2977  168991      6          1510280818            1510456811    129    3\n",
       "              2978  169031     10          1510287019            1510613142     27    1\n",
       "              2979  169049      7          1510292348            1510392612     43    1\n",
       "              2980  169084     11          1510303482            1510927533     94    1\n",
       "              2981  169106     23          1510312431            1511054357    215    2\n",
       "              2982  169132     18          1510324837            1511090706     75    2\n",
       "              2983  169197     38          1510373093            1510890780     66    1\n",
       "              2984  169217     28          1510377281            1510877581     38    1\n",
       "              2985  169269      4          1510388952            1510388952      7    1\n",
       "              2986  169276      6          1510391145            1511008391     50    1\n",
       "              2987  169299      9          1510397978            1511187978     27    1\n",
       "              2988  169318      8          1510407061            1510615622    154    2\n",
       "              2989  169393     14          1510464820            1511147607    187    3\n",
       "              2990  169445     13          1510487420            1510645072     84    1\n",
       "              2991  169598     35          1510618726            1510983354     63    2\n",
       "              2992  169613     11          1510627070            1510746988     12    1\n",
       "              2993  169614      9          1510627121            1510889773     33    1\n",
       "              2994  169691      6          1510657422            1510706666     73    1\n",
       "              2995  169699     20          1510662595            1511217077    153    3\n",
       "              2996  169815     13          1510753437            1511159975     57    1\n",
       "              2997  169832     12          1510793074            1511142183     62    1\n",
       "              2998  169934     14          1510841381            1510971292     68    2\n",
       "              2999  169976     16          1510908302            1511184987     27    1\n",
       "              \n",
       "              [3000 rows x 6 columns])])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "shop = pd.read_excel('shopmall.xlsx',None)\n",
    "shop"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 数据情况\n",
    "\n",
    "\n",
    "数据由3个单元表组成：\n",
    "\n",
    "订单信息：\n",
    "\n",
    "* 订单ID\n",
    "* 客户ID\n",
    "* 订单状态\n",
    "    * 1表示正常完成订单\n",
    "    * 0表示未完成订单\n",
    "* 优惠类型\n",
    "    * 0表示无优惠\n",
    "    * 1表示优惠\n",
    "货物信息：\n",
    "\n",
    "* 订单ID\n",
    "* 货物ID\n",
    "* 货物名称\n",
    "* 优惠额度\n",
    "    * 分组显示优惠额度\n",
    "\n",
    "顾客信息：\n",
    "\n",
    "* 客户ID\n",
    "* 登陆次数\n",
    "* 注册时间(距1970-1-1的秒数)\n",
    "* 本次购买时间(距1970-1-1的秒数)\n",
    "* 经验值\n",
    "* 订单数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据整体概览"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单ID</th>\n",
       "      <th>客户ID</th>\n",
       "      <th>订单状态</th>\n",
       "      <th>优惠类型</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>47739</td>\n",
       "      <td>5245</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>341269</td>\n",
       "      <td>5245</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>32690</td>\n",
       "      <td>5254</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>45641</td>\n",
       "      <td>5254</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>66116</td>\n",
       "      <td>5254</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     订单ID  客户ID  订单状态  优惠类型\n",
       "0   47739  5245     1     0\n",
       "1  341269  5245     0     0\n",
       "2   32690  5254     1     0\n",
       "3   45641  5254     1     0\n",
       "4   66116  5254     1     0"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dingdan = shop['订单信息']\n",
    "dingdan.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单ID</th>\n",
       "      <th>货物ID</th>\n",
       "      <th>货物名称</th>\n",
       "      <th>优惠额度</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>264971</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>264994</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>266829</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>267232</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>269051</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     订单ID    货物ID      货物名称 优惠额度\n",
       "0  264971  103247  自然乐园水果礼盒  >15\n",
       "1  264994  103247  自然乐园水果礼盒  >15\n",
       "2  266829  103247  自然乐园水果礼盒  >15\n",
       "3  267232  103247  自然乐园水果礼盒  >15\n",
       "4  269051  103247  自然乐园水果礼盒  >15"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "huowu = shop['货物信息']\n",
    "huowu.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5245</td>\n",
       "      <td>55</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1495339734</td>\n",
       "      <td>206</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5254</td>\n",
       "      <td>69</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1499041945</td>\n",
       "      <td>428</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5286</td>\n",
       "      <td>57</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1509936376</td>\n",
       "      <td>280</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5292</td>\n",
       "      <td>184</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1510135868</td>\n",
       "      <td>643</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5474</td>\n",
       "      <td>71</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1481185064</td>\n",
       "      <td>61</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   客户ID  登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)  经验值 订单数\n",
       "0  5245    55          1430413266            1495339734  206   1\n",
       "1  5254    69          1430413266            1499041945  428  13\n",
       "2  5286    57          1430413266            1509936376  280   1\n",
       "3  5292   184          1430413266            1510135868  643   5\n",
       "4  5474    71          1430413266            1481185064   61   2"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guke = shop['顾客信息']\n",
    "guke.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 数据规整"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 29150 entries, 0 to 29149\n",
      "Data columns (total 4 columns):\n",
      "订单ID    29150 non-null int64\n",
      "客户ID    29150 non-null int64\n",
      "订单状态    29150 non-null int64\n",
      "优惠类型    29150 non-null int64\n",
      "dtypes: int64(4)\n",
      "memory usage: 911.0 KB\n"
     ]
    }
   ],
   "source": [
    "dingdan.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 3000 entries, 0 to 2999\n",
      "Data columns (total 6 columns):\n",
      "客户ID                    3000 non-null int64\n",
      "登陆次数                    3000 non-null int64\n",
      "注册时间(距1970-1-1的秒数)      3000 non-null int64\n",
      "本次购买时间(距1970-1-1的秒数)    3000 non-null int64\n",
      "经验值                     3000 non-null int64\n",
      "订单数                     3000 non-null object\n",
      "dtypes: int64(5), object(1)\n",
      "memory usage: 140.7+ KB\n"
     ]
    }
   ],
   "source": [
    "guke.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 3130 entries, 0 to 3129\n",
      "Data columns (total 4 columns):\n",
      "订单ID    3130 non-null int64\n",
      "货物ID    3130 non-null int64\n",
      "货物名称    3130 non-null object\n",
      "优惠额度    3130 non-null object\n",
      "dtypes: int64(2), object(2)\n",
      "memory usage: 97.9+ KB\n"
     ]
    }
   ],
   "source": [
    "huowu.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(guke['订单数'][0]) == int"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>6243</td>\n",
       "      <td>2829</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1511178943</td>\n",
       "      <td>1172</td>\n",
       "      <td>yb8e507534</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    客户ID  登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)   经验值         订单数\n",
       "46  6243  2829          1430413266            1511178943  1172  yb8e507534"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def p(x):\n",
    "    return False if type(x) == int else True\n",
    "guke[guke['订单数'].map(p)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>6022</td>\n",
       "      <td>319</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1510333397</td>\n",
       "      <td>1196</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>6045</td>\n",
       "      <td>219</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1511231521</td>\n",
       "      <td>1155</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>6243</td>\n",
       "      <td>2829</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1511178943</td>\n",
       "      <td>1172</td>\n",
       "      <td>yb8e507534</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>6380</td>\n",
       "      <td>206</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1510636442</td>\n",
       "      <td>1093</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>6412</td>\n",
       "      <td>192</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1511229694</td>\n",
       "      <td>1194</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>6443</td>\n",
       "      <td>331</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1511053190</td>\n",
       "      <td>1157</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>13798</td>\n",
       "      <td>149</td>\n",
       "      <td>1433895123</td>\n",
       "      <td>1504761787</td>\n",
       "      <td>1151</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>151</th>\n",
       "      <td>17404</td>\n",
       "      <td>861</td>\n",
       "      <td>1434003913</td>\n",
       "      <td>1510715536</td>\n",
       "      <td>1119</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212</th>\n",
       "      <td>24305</td>\n",
       "      <td>62</td>\n",
       "      <td>1446356049</td>\n",
       "      <td>1505705335</td>\n",
       "      <td>1168</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>256</th>\n",
       "      <td>25367</td>\n",
       "      <td>539</td>\n",
       "      <td>1449391974</td>\n",
       "      <td>1511061366</td>\n",
       "      <td>1040</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>301</th>\n",
       "      <td>26930</td>\n",
       "      <td>227</td>\n",
       "      <td>1451974845</td>\n",
       "      <td>1510923866</td>\n",
       "      <td>1092</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>318</th>\n",
       "      <td>27290</td>\n",
       "      <td>261</td>\n",
       "      <td>1452162217</td>\n",
       "      <td>1493392517</td>\n",
       "      <td>1048</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>337</th>\n",
       "      <td>27888</td>\n",
       "      <td>94</td>\n",
       "      <td>1452586643</td>\n",
       "      <td>1507551155</td>\n",
       "      <td>1046</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343</th>\n",
       "      <td>28472</td>\n",
       "      <td>330</td>\n",
       "      <td>1453080092</td>\n",
       "      <td>1493392736</td>\n",
       "      <td>1185</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>346</th>\n",
       "      <td>28584</td>\n",
       "      <td>139</td>\n",
       "      <td>1453192060</td>\n",
       "      <td>1510970732</td>\n",
       "      <td>1058</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>352</th>\n",
       "      <td>28804</td>\n",
       "      <td>99</td>\n",
       "      <td>1453515638</td>\n",
       "      <td>1484614553</td>\n",
       "      <td>1006</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>353</th>\n",
       "      <td>29134</td>\n",
       "      <td>447</td>\n",
       "      <td>1453630137</td>\n",
       "      <td>1511096733</td>\n",
       "      <td>1198</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>423</th>\n",
       "      <td>34432</td>\n",
       "      <td>114</td>\n",
       "      <td>1457611103</td>\n",
       "      <td>1510216310</td>\n",
       "      <td>1169</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>429</th>\n",
       "      <td>34624</td>\n",
       "      <td>310</td>\n",
       "      <td>1457696643</td>\n",
       "      <td>1508483586</td>\n",
       "      <td>1161</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>438</th>\n",
       "      <td>35454</td>\n",
       "      <td>168</td>\n",
       "      <td>1458214800</td>\n",
       "      <td>1509692648</td>\n",
       "      <td>1177</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>479</th>\n",
       "      <td>40395</td>\n",
       "      <td>104</td>\n",
       "      <td>1459221049</td>\n",
       "      <td>1489904966</td>\n",
       "      <td>1016</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>483</th>\n",
       "      <td>40762</td>\n",
       "      <td>255</td>\n",
       "      <td>1459348524</td>\n",
       "      <td>1493390307</td>\n",
       "      <td>1162</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>485</th>\n",
       "      <td>40774</td>\n",
       "      <td>258</td>\n",
       "      <td>1459349272</td>\n",
       "      <td>1493390651</td>\n",
       "      <td>1172</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>486</th>\n",
       "      <td>40814</td>\n",
       "      <td>254</td>\n",
       "      <td>1459394344</td>\n",
       "      <td>1493390961</td>\n",
       "      <td>1153</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>487</th>\n",
       "      <td>40816</td>\n",
       "      <td>249</td>\n",
       "      <td>1459394479</td>\n",
       "      <td>1493391015</td>\n",
       "      <td>1174</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>488</th>\n",
       "      <td>40821</td>\n",
       "      <td>250</td>\n",
       "      <td>1459394908</td>\n",
       "      <td>1493391132</td>\n",
       "      <td>1157</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>489</th>\n",
       "      <td>40822</td>\n",
       "      <td>248</td>\n",
       "      <td>1459395041</td>\n",
       "      <td>1493391160</td>\n",
       "      <td>1158</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>491</th>\n",
       "      <td>41041</td>\n",
       "      <td>255</td>\n",
       "      <td>1459425488</td>\n",
       "      <td>1493390821</td>\n",
       "      <td>1156</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>492</th>\n",
       "      <td>41167</td>\n",
       "      <td>230</td>\n",
       "      <td>1459477835</td>\n",
       "      <td>1493393124</td>\n",
       "      <td>1101</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>493</th>\n",
       "      <td>41176</td>\n",
       "      <td>231</td>\n",
       "      <td>1459478743</td>\n",
       "      <td>1493393215</td>\n",
       "      <td>1115</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>835</th>\n",
       "      <td>73821</td>\n",
       "      <td>495</td>\n",
       "      <td>1467262926</td>\n",
       "      <td>1510312393</td>\n",
       "      <td>1188</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>853</th>\n",
       "      <td>75497</td>\n",
       "      <td>198</td>\n",
       "      <td>1467428928</td>\n",
       "      <td>1507124194</td>\n",
       "      <td>1084</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>881</th>\n",
       "      <td>90319</td>\n",
       "      <td>228</td>\n",
       "      <td>1468291859</td>\n",
       "      <td>1511247205</td>\n",
       "      <td>1097</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>896</th>\n",
       "      <td>107012</td>\n",
       "      <td>122</td>\n",
       "      <td>1469366158</td>\n",
       "      <td>1510105275</td>\n",
       "      <td>1031</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>948</th>\n",
       "      <td>109001</td>\n",
       "      <td>284</td>\n",
       "      <td>1471478513</td>\n",
       "      <td>1504416747</td>\n",
       "      <td>1161</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1037</th>\n",
       "      <td>111532</td>\n",
       "      <td>425</td>\n",
       "      <td>1474442858</td>\n",
       "      <td>1507202783</td>\n",
       "      <td>1192</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1041</th>\n",
       "      <td>111684</td>\n",
       "      <td>337</td>\n",
       "      <td>1474511468</td>\n",
       "      <td>1507599799</td>\n",
       "      <td>1168</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1057</th>\n",
       "      <td>113615</td>\n",
       "      <td>88</td>\n",
       "      <td>1475145879</td>\n",
       "      <td>1510134606</td>\n",
       "      <td>1077</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1082</th>\n",
       "      <td>117654</td>\n",
       "      <td>38</td>\n",
       "      <td>1476364893</td>\n",
       "      <td>1501378108</td>\n",
       "      <td>1090</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1083</th>\n",
       "      <td>117991</td>\n",
       "      <td>350</td>\n",
       "      <td>1476533990</td>\n",
       "      <td>1511133301</td>\n",
       "      <td>1166</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1098</th>\n",
       "      <td>119069</td>\n",
       "      <td>79</td>\n",
       "      <td>1477651292</td>\n",
       "      <td>1510555284</td>\n",
       "      <td>1074</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1185</th>\n",
       "      <td>120461</td>\n",
       "      <td>646</td>\n",
       "      <td>1479954449</td>\n",
       "      <td>1510884312</td>\n",
       "      <td>1174</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1204</th>\n",
       "      <td>120607</td>\n",
       "      <td>380</td>\n",
       "      <td>1479976950</td>\n",
       "      <td>1497946855</td>\n",
       "      <td>1110</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1215</th>\n",
       "      <td>120673</td>\n",
       "      <td>357</td>\n",
       "      <td>1479987350</td>\n",
       "      <td>1511046205</td>\n",
       "      <td>1117</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1218</th>\n",
       "      <td>120688</td>\n",
       "      <td>308</td>\n",
       "      <td>1479989396</td>\n",
       "      <td>1511166786</td>\n",
       "      <td>1129</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1272</th>\n",
       "      <td>121146</td>\n",
       "      <td>229</td>\n",
       "      <td>1480080870</td>\n",
       "      <td>1510816938</td>\n",
       "      <td>1058</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1310</th>\n",
       "      <td>121479</td>\n",
       "      <td>133</td>\n",
       "      <td>1480152347</td>\n",
       "      <td>1511085465</td>\n",
       "      <td>1027</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1336</th>\n",
       "      <td>121774</td>\n",
       "      <td>346</td>\n",
       "      <td>1480246310</td>\n",
       "      <td>1511236674</td>\n",
       "      <td>1144</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1381</th>\n",
       "      <td>122215</td>\n",
       "      <td>95</td>\n",
       "      <td>1480405503</td>\n",
       "      <td>1500907653</td>\n",
       "      <td>1024</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1724</th>\n",
       "      <td>125468</td>\n",
       "      <td>93</td>\n",
       "      <td>1480931843</td>\n",
       "      <td>1511162072</td>\n",
       "      <td>1093</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2158</th>\n",
       "      <td>130080</td>\n",
       "      <td>477</td>\n",
       "      <td>1481551187</td>\n",
       "      <td>1511129423</td>\n",
       "      <td>1128</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2172</th>\n",
       "      <td>130188</td>\n",
       "      <td>436</td>\n",
       "      <td>1481593369</td>\n",
       "      <td>1511070581</td>\n",
       "      <td>1177</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2220</th>\n",
       "      <td>130555</td>\n",
       "      <td>73</td>\n",
       "      <td>1481625545</td>\n",
       "      <td>1510736484</td>\n",
       "      <td>1134</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2265</th>\n",
       "      <td>130919</td>\n",
       "      <td>620</td>\n",
       "      <td>1481679317</td>\n",
       "      <td>1509710012</td>\n",
       "      <td>1074</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2332</th>\n",
       "      <td>131953</td>\n",
       "      <td>230</td>\n",
       "      <td>1481804890</td>\n",
       "      <td>1511178032</td>\n",
       "      <td>1130</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2640</th>\n",
       "      <td>136976</td>\n",
       "      <td>96</td>\n",
       "      <td>1484221758</td>\n",
       "      <td>1499592441</td>\n",
       "      <td>1049</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2691</th>\n",
       "      <td>137731</td>\n",
       "      <td>74</td>\n",
       "      <td>1484720616</td>\n",
       "      <td>1510481229</td>\n",
       "      <td>1181</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2855</th>\n",
       "      <td>153977</td>\n",
       "      <td>159</td>\n",
       "      <td>1497005694</td>\n",
       "      <td>1511026370</td>\n",
       "      <td>1054</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2858</th>\n",
       "      <td>154365</td>\n",
       "      <td>205</td>\n",
       "      <td>1497271670</td>\n",
       "      <td>1511163840</td>\n",
       "      <td>1086</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2923</th>\n",
       "      <td>163649</td>\n",
       "      <td>56</td>\n",
       "      <td>1503992085</td>\n",
       "      <td>1511233009</td>\n",
       "      <td>1072</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>92 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        客户ID  登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)   经验值         订单数\n",
       "38      6022   319          1430413266            1510333397  1196          21\n",
       "42      6045   219          1430413266            1511231521  1155          31\n",
       "46      6243  2829          1430413266            1511178943  1172  yb8e507534\n",
       "52      6380   206          1430413266            1510636442  1093          10\n",
       "54      6412   192          1430413266            1511229694  1194          24\n",
       "55      6443   331          1430413266            1511053190  1157          12\n",
       "138    13798   149          1433895123            1504761787  1151          15\n",
       "151    17404   861          1434003913            1510715536  1119           9\n",
       "212    24305    62          1446356049            1505705335  1168          14\n",
       "256    25367   539          1449391974            1511061366  1040          10\n",
       "301    26930   227          1451974845            1510923866  1092          17\n",
       "318    27290   261          1452162217            1493392517  1048           1\n",
       "337    27888    94          1452586643            1507551155  1046          15\n",
       "343    28472   330          1453080092            1493392736  1185           3\n",
       "346    28584   139          1453192060            1510970732  1058          13\n",
       "352    28804    99          1453515638            1484614553  1006          12\n",
       "353    29134   447          1453630137            1511096733  1198          19\n",
       "423    34432   114          1457611103            1510216310  1169          16\n",
       "429    34624   310          1457696643            1508483586  1161          18\n",
       "438    35454   168          1458214800            1509692648  1177          17\n",
       "479    40395   104          1459221049            1489904966  1016          15\n",
       "483    40762   255          1459348524            1493390307  1162           2\n",
       "485    40774   258          1459349272            1493390651  1172           2\n",
       "486    40814   254          1459394344            1493390961  1153           2\n",
       "487    40816   249          1459394479            1493391015  1174           2\n",
       "488    40821   250          1459394908            1493391132  1157           2\n",
       "489    40822   248          1459395041            1493391160  1158           2\n",
       "491    41041   255          1459425488            1493390821  1156           2\n",
       "492    41167   230          1459477835            1493393124  1101           2\n",
       "493    41176   231          1459478743            1493393215  1115           2\n",
       "...      ...   ...                 ...                   ...   ...         ...\n",
       "835    73821   495          1467262926            1510312393  1188          16\n",
       "853    75497   198          1467428928            1507124194  1084          12\n",
       "881    90319   228          1468291859            1511247205  1097          17\n",
       "896   107012   122          1469366158            1510105275  1031          17\n",
       "948   109001   284          1471478513            1504416747  1161           2\n",
       "1037  111532   425          1474442858            1507202783  1192          11\n",
       "1041  111684   337          1474511468            1507599799  1168          17\n",
       "1057  113615    88          1475145879            1510134606  1077          11\n",
       "1082  117654    38          1476364893            1501378108  1090           8\n",
       "1083  117991   350          1476533990            1511133301  1166          12\n",
       "1098  119069    79          1477651292            1510555284  1074          17\n",
       "1185  120461   646          1479954449            1510884312  1174          14\n",
       "1204  120607   380          1479976950            1497946855  1110          16\n",
       "1215  120673   357          1479987350            1511046205  1117           9\n",
       "1218  120688   308          1479989396            1511166786  1129          12\n",
       "1272  121146   229          1480080870            1510816938  1058          15\n",
       "1310  121479   133          1480152347            1511085465  1027          12\n",
       "1336  121774   346          1480246310            1511236674  1144           8\n",
       "1381  122215    95          1480405503            1500907653  1024          15\n",
       "1724  125468    93          1480931843            1511162072  1093          14\n",
       "2158  130080   477          1481551187            1511129423  1128          13\n",
       "2172  130188   436          1481593369            1511070581  1177          14\n",
       "2220  130555    73          1481625545            1510736484  1134          16\n",
       "2265  130919   620          1481679317            1509710012  1074           6\n",
       "2332  131953   230          1481804890            1511178032  1130          14\n",
       "2640  136976    96          1484221758            1499592441  1049          10\n",
       "2691  137731    74          1484720616            1510481229  1181          18\n",
       "2855  153977   159          1497005694            1511026370  1054          20\n",
       "2858  154365   205          1497271670            1511163840  1086          13\n",
       "2923  163649    56          1503992085            1511233009  1072          11\n",
       "\n",
       "[92 rows x 6 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查询类似条件的顾客，根据其他人的订单数情况填充错误值\n",
    "guke[ (guke['经验值'] > 1000) & (guke['经验值'] < 1200)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>5661</td>\n",
       "      <td>11675</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1511224143</td>\n",
       "      <td>34701</td>\n",
       "      <td>487</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>6243</td>\n",
       "      <td>2829</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1511178943</td>\n",
       "      <td>1172</td>\n",
       "      <td>yb8e507534</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>6368</td>\n",
       "      <td>5332</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1511242197</td>\n",
       "      <td>10741</td>\n",
       "      <td>136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>163</th>\n",
       "      <td>20397</td>\n",
       "      <td>3778</td>\n",
       "      <td>1436344864</td>\n",
       "      <td>1511228091</td>\n",
       "      <td>17158</td>\n",
       "      <td>315</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>166</th>\n",
       "      <td>20600</td>\n",
       "      <td>3107</td>\n",
       "      <td>1436432061</td>\n",
       "      <td>1511102956</td>\n",
       "      <td>15398</td>\n",
       "      <td>209</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>218</th>\n",
       "      <td>24705</td>\n",
       "      <td>3264</td>\n",
       "      <td>1448253287</td>\n",
       "      <td>1511218542</td>\n",
       "      <td>12626</td>\n",
       "      <td>158</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>253</th>\n",
       "      <td>25304</td>\n",
       "      <td>3509</td>\n",
       "      <td>1449304809</td>\n",
       "      <td>1511243343</td>\n",
       "      <td>13673</td>\n",
       "      <td>252</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>801</th>\n",
       "      <td>71153</td>\n",
       "      <td>6526</td>\n",
       "      <td>1467117300</td>\n",
       "      <td>1511245124</td>\n",
       "      <td>12508</td>\n",
       "      <td>180</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      客户ID   登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)    经验值         订单数\n",
       "12    5661  11675          1430413266            1511224143  34701         487\n",
       "46    6243   2829          1430413266            1511178943   1172  yb8e507534\n",
       "51    6368   5332          1430413266            1511242197  10741         136\n",
       "163  20397   3778          1436344864            1511228091  17158         315\n",
       "166  20600   3107          1436432061            1511102956  15398         209\n",
       "218  24705   3264          1448253287            1511218542  12626         158\n",
       "253  25304   3509          1449304809            1511243343  13673         252\n",
       "801  71153   6526          1467117300            1511245124  12508         180"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 用经验值区分，用户太多，分不开\n",
    "guke[guke['登陆次数'] > 2800]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 3000 entries, 0 to 2999\n",
      "Data columns (total 6 columns):\n",
      "客户ID                    3000 non-null int64\n",
      "登陆次数                    3000 non-null int64\n",
      "注册时间(距1970-1-1的秒数)      3000 non-null int64\n",
      "本次购买时间(距1970-1-1的秒数)    3000 non-null int64\n",
      "经验值                     3000 non-null int64\n",
      "订单数                     2999 non-null float64\n",
      "dtypes: float64(1), int64(5)\n",
      "memory usage: 140.7 KB\n"
     ]
    }
   ],
   "source": [
    "guke.loc[46,'订单数'] = np.nan\n",
    "guke['订单数'] = guke['订单数'].astype(np.float)#转换类型\n",
    "guke.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 给错误值赋值\n",
    "guke.loc[46,'订单数'] = guke[(guke['登陆次数'] > 2800)]['订单数'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "248.14285714285714"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guke.loc[46,'订单数']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 数据异常值的发现"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单ID</th>\n",
       "      <th>客户ID</th>\n",
       "      <th>订单状态</th>\n",
       "      <th>优惠类型</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>29150.000000</td>\n",
       "      <td>29150.000000</td>\n",
       "      <td>29150.000000</td>\n",
       "      <td>29150.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>249006.753413</td>\n",
       "      <td>61639.974305</td>\n",
       "      <td>0.828027</td>\n",
       "      <td>0.513242</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>116588.726172</td>\n",
       "      <td>49897.424880</td>\n",
       "      <td>0.377363</td>\n",
       "      <td>0.499833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>29787.000000</td>\n",
       "      <td>5245.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>167595.750000</td>\n",
       "      <td>20428.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>254617.500000</td>\n",
       "      <td>42854.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>344684.500000</td>\n",
       "      <td>120409.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>447649.000000</td>\n",
       "      <td>169976.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                订单ID           客户ID          订单状态          优惠类型\n",
       "count   29150.000000   29150.000000  29150.000000  29150.000000\n",
       "mean   249006.753413   61639.974305      0.828027      0.513242\n",
       "std    116588.726172   49897.424880      0.377363      0.499833\n",
       "min     29787.000000    5245.000000      0.000000      0.000000\n",
       "25%    167595.750000   20428.000000      1.000000      0.000000\n",
       "50%    254617.500000   42854.000000      1.000000      1.000000\n",
       "75%    344684.500000  120409.000000      1.000000      1.000000\n",
       "max    447649.000000  169976.000000      1.000000      1.000000"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dingdan.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单ID</th>\n",
       "      <th>货物ID</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>3130.000000</td>\n",
       "      <td>3130.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>274072.237380</td>\n",
       "      <td>102503.992652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>10460.610208</td>\n",
       "      <td>905.268944</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>253908.000000</td>\n",
       "      <td>100891.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>266745.500000</td>\n",
       "      <td>101662.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>274352.000000</td>\n",
       "      <td>102103.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>282988.250000</td>\n",
       "      <td>103262.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>292811.000000</td>\n",
       "      <td>104456.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                订单ID           货物ID\n",
       "count    3130.000000    3130.000000\n",
       "mean   274072.237380  102503.992652\n",
       "std     10460.610208     905.268944\n",
       "min    253908.000000  100891.000000\n",
       "25%    266745.500000  101662.000000\n",
       "50%    274352.000000  102103.000000\n",
       "75%    282988.250000  103262.000000\n",
       "max    292811.000000  104456.000000"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "huowu.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>3000.000000</td>\n",
       "      <td>3000.000000</td>\n",
       "      <td>3.000000e+03</td>\n",
       "      <td>3.000000e+03</td>\n",
       "      <td>3000.000000</td>\n",
       "      <td>3000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>102669.020667</td>\n",
       "      <td>157.338333</td>\n",
       "      <td>1.474146e+09</td>\n",
       "      <td>1.496260e+09</td>\n",
       "      <td>672.358667</td>\n",
       "      <td>8.528714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>44547.168855</td>\n",
       "      <td>406.994135</td>\n",
       "      <td>1.609252e+07</td>\n",
       "      <td>1.269127e+07</td>\n",
       "      <td>1646.677601</td>\n",
       "      <td>23.405667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>5245.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>1.430413e+09</td>\n",
       "      <td>1.469535e+09</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>67114.250000</td>\n",
       "      <td>19.000000</td>\n",
       "      <td>1.465985e+09</td>\n",
       "      <td>1.482673e+09</td>\n",
       "      <td>51.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>123393.000000</td>\n",
       "      <td>46.000000</td>\n",
       "      <td>1.480582e+09</td>\n",
       "      <td>1.496886e+09</td>\n",
       "      <td>146.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>130771.250000</td>\n",
       "      <td>131.000000</td>\n",
       "      <td>1.481637e+09</td>\n",
       "      <td>1.510270e+09</td>\n",
       "      <td>593.250000</td>\n",
       "      <td>6.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>169976.000000</td>\n",
       "      <td>11675.000000</td>\n",
       "      <td>1.510908e+09</td>\n",
       "      <td>1.511247e+09</td>\n",
       "      <td>34701.000000</td>\n",
       "      <td>487.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                客户ID          登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)  \\\n",
       "count    3000.000000   3000.000000        3.000000e+03          3.000000e+03   \n",
       "mean   102669.020667    157.338333        1.474146e+09          1.496260e+09   \n",
       "std     44547.168855    406.994135        1.609252e+07          1.269127e+07   \n",
       "min      5245.000000      4.000000        1.430413e+09          1.469535e+09   \n",
       "25%     67114.250000     19.000000        1.465985e+09          1.482673e+09   \n",
       "50%    123393.000000     46.000000        1.480582e+09          1.496886e+09   \n",
       "75%    130771.250000    131.000000        1.481637e+09          1.510270e+09   \n",
       "max    169976.000000  11675.000000        1.510908e+09          1.511247e+09   \n",
       "\n",
       "                经验值          订单数  \n",
       "count   3000.000000  3000.000000  \n",
       "mean     672.358667     8.528714  \n",
       "std     1646.677601    23.405667  \n",
       "min        7.000000     0.000000  \n",
       "25%       51.000000     1.000000  \n",
       "50%      146.000000     2.000000  \n",
       "75%      593.250000     6.000000  \n",
       "max    34701.000000   487.000000  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guke.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 数据规整完毕"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 研究方法\n",
    "# 订单分析\n",
    "\n",
    "## 分析订单的优惠额度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单ID</th>\n",
       "      <th>货物ID</th>\n",
       "      <th>货物名称</th>\n",
       "      <th>优惠额度</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>264971</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>264994</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>266829</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>267232</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>269051</td>\n",
       "      <td>103247</td>\n",
       "      <td>自然乐园水果礼盒</td>\n",
       "      <td>&gt;15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     订单ID    货物ID      货物名称 优惠额度\n",
       "0  264971  103247  自然乐园水果礼盒  >15\n",
       "1  264994  103247  自然乐园水果礼盒  >15\n",
       "2  266829  103247  自然乐园水果礼盒  >15\n",
       "3  267232  103247  自然乐园水果礼盒  >15\n",
       "4  269051  103247  自然乐园水果礼盒  >15"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "huowu.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "优惠额度\n",
       "0        1439\n",
       "0-2       584\n",
       "10-15      38\n",
       "2-5       596\n",
       "5-10      310\n",
       ">15       163\n",
       "dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "youhui = huowu.groupby('优惠额度').size()\n",
    "youhui"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x228f88e3748>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw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JEmauJzBIEmSAIiIbmAmcLApfDswB7irEY+ImyhzFa4BJtV1UymDGy/UWF9ELAY+B+6kVCDsBrYBp69wGVOB+RExUD8/3PTd28DKf3l7kiRpnFnBIEmSAMjMT4GHKC0PDcspFQjN634FngLeAd6lzFg4BmzIzHuADUAvJVkxB7gPmFfjk4HzwHVAqz7NmZTKheXAtcBG4EHgFPDxGNymJEkaJyYYJEnSRZk53DiOiNuABZQqhEZsWkRMB1YDz1NaKG4A1gCrIuI9YBnwNDCcmV9R5i5srPFplETBIkqyYQWwr+kSuoDjmXkaeAY4QGmn+CQze8fhliVJ0hixRUKSJLUyGXiLMjNhVlP8OeA48CNwP2W4437gyfr9z5n5eESspQxpHKzxXuAPLs1r2AI8BjwKvBIRq4EllEdRbqlPqpgCvAScBZ6IiPWUoZDbM7OxryRJmiB8ioQkSRohIvqB74HBzHyj/vl/E/gFmAF0ZebQP9hvJ/BhZn4WEc8CPcCmzNwbEZOAPZRExpm6/2zgh8w8O2qfKcDdwLHMPN/eXUqSpLFmgkGSJF01EXE9jGzFkCRJ/w8mGCRJkiRJUtsc8ihJkiRJktpmgkGSJEmSJLXNBIMkSZIkSWqbCQZJkiRJktQ2EwySJEmSJKltJhgkSZIkSVLb/gahUbCWsqfTTgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1296x864 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "youhui.plot.bar(figsize=(18,12))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 分析订单商品排行\n",
    "\n",
    "#### 原价商品销量前十"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>货物名称</th>\n",
       "      <th>优惠额度</th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>海南香蕉</td>\n",
       "      <td>0</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>安慕希希腊酸奶（原味）</td>\n",
       "      <td>0</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>冷冻鲜肉</td>\n",
       "      <td>0</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>新希望酸奶初心</td>\n",
       "      <td>0</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>静宁小苹果</td>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>金堂脐橙</td>\n",
       "      <td>0</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>冰糖橙</td>\n",
       "      <td>0</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>土飞鸡</td>\n",
       "      <td>0</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>福临门丝苗米</td>\n",
       "      <td>0</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>好迪</td>\n",
       "      <td>0</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          货物名称 优惠额度   0\n",
       "0         海南香蕉    0  60\n",
       "1  安慕希希腊酸奶（原味）    0  57\n",
       "2         冷冻鲜肉    0  51\n",
       "3      新希望酸奶初心    0  50\n",
       "4        静宁小苹果    0  48\n",
       "5         金堂脐橙    0  42\n",
       "6          冰糖橙    0  40\n",
       "7          土飞鸡    0  37\n",
       "8       福临门丝苗米    0  36\n",
       "9           好迪    0  35"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z = huowu[huowu['优惠额度']=='0'].groupby(['货物名称','优惠额度']).size().sort_values(ascending=False).reset_index()[:10]\n",
    "z"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 优惠商品销量前十"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>货物名称</th>\n",
       "      <th>优惠额度</th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>蒲江耙耙柑</td>\n",
       "      <td>2-5</td>\n",
       "      <td>118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>蒲江不知火丑柑【原产地直供】</td>\n",
       "      <td>2-5</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>藕</td>\n",
       "      <td>2-5</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>青椒</td>\n",
       "      <td>2-5</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>泰国龙眼【进口商品】800g</td>\n",
       "      <td>0-2</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>西红柿</td>\n",
       "      <td>0-2</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>云南青枣</td>\n",
       "      <td>&gt;15</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>小葱</td>\n",
       "      <td>5-10</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>新土豆</td>\n",
       "      <td>5-10</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>小白菜</td>\n",
       "      <td>0-2</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             货物名称  优惠额度    0\n",
       "0           蒲江耙耙柑   2-5  118\n",
       "1  蒲江不知火丑柑【原产地直供】   2-5   61\n",
       "2               藕   2-5   54\n",
       "3              青椒   2-5   41\n",
       "4  泰国龙眼【进口商品】800g   0-2   39\n",
       "5             西红柿   0-2   38\n",
       "6            云南青枣   >15   37\n",
       "7              小葱  5-10   36\n",
       "8             新土豆  5-10   34\n",
       "9             小白菜   0-2   34"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = huowu[- (huowu['优惠额度']== '0')].groupby(['货物名称','优惠额度']).size().sort_values(ascending=False).reset_index()[:10]\n",
    "y"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 客户匹配\n",
    "### “无价值客户”指标量化定义\n",
    "当客户已成交订单中，优惠商品的订单超过75%时，定义客户为无价值客户\n",
    "\n",
    "\n",
    "#### 分离正常客户和无价值客户"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单ID</th>\n",
       "      <th>客户ID</th>\n",
       "      <th>订单状态</th>\n",
       "      <th>优惠类型</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>47739</td>\n",
       "      <td>5245</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>341269</td>\n",
       "      <td>5245</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>32690</td>\n",
       "      <td>5254</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>45641</td>\n",
       "      <td>5254</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>66116</td>\n",
       "      <td>5254</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     订单ID  客户ID  订单状态  优惠类型\n",
       "0   47739  5245     1     0\n",
       "1  341269  5245     0     0\n",
       "2   32690  5254     1     0\n",
       "3   45641  5254     1     0\n",
       "4   66116  5254     1     0"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dingdan.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "订单状态\n",
       "0     5013\n",
       "1    24137\n",
       "dtype: int64"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dingdan.groupby('订单状态').size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>优惠类型</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>客户ID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5245</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5254</th>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5286</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5292</th>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5474</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5544</th>\n",
       "      <td>75</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5547</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5552</th>\n",
       "      <td>55</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5560</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5580</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5625</th>\n",
       "      <td>10</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5628</th>\n",
       "      <td>104</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5661</th>\n",
       "      <td>297</td>\n",
       "      <td>126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5690</th>\n",
       "      <td>73</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5699</th>\n",
       "      <td>85</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5701</th>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5723</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5725</th>\n",
       "      <td>56</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5726</th>\n",
       "      <td>87</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5727</th>\n",
       "      <td>24</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5728</th>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5734</th>\n",
       "      <td>45</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5740</th>\n",
       "      <td>12</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5767</th>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5785</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5789</th>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5804</th>\n",
       "      <td>15</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5816</th>\n",
       "      <td>12</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5880</th>\n",
       "      <td>42</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5912</th>\n",
       "      <td>18</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168758</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168792</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168831</th>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168834</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168948</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168976</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168981</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168991</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169031</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169049</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169084</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169106</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169132</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169197</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169217</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169269</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169276</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169299</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169318</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169393</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169445</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169598</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169613</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169614</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169691</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169699</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169815</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169832</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169934</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169976</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3000 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "优惠类型      0    1\n",
       "客户ID            \n",
       "5245      1    0\n",
       "5254      8    1\n",
       "5286      1    1\n",
       "5292      4    2\n",
       "5474      1    1\n",
       "5544     75   16\n",
       "5547      5    4\n",
       "5552     55   96\n",
       "5560      0    1\n",
       "5580      0    2\n",
       "5625     10    2\n",
       "5628    104   52\n",
       "5661    297  126\n",
       "5690     73   95\n",
       "5699     85   17\n",
       "5701      6    1\n",
       "5723      0    1\n",
       "5725     56   31\n",
       "5726     87   96\n",
       "5727     24    8\n",
       "5728      7    8\n",
       "5734     45   43\n",
       "5740     12    7\n",
       "5767      8    5\n",
       "5785      2    1\n",
       "5789      9    6\n",
       "5804     15   12\n",
       "5816     12    3\n",
       "5880     42   28\n",
       "5912     18    4\n",
       "...     ...  ...\n",
       "168758    0    2\n",
       "168792    0    1\n",
       "168831    3    6\n",
       "168834    0    3\n",
       "168948    0    1\n",
       "168976    1    1\n",
       "168981    0    2\n",
       "168991    0    3\n",
       "169031    1    0\n",
       "169049    1    0\n",
       "169084    1    0\n",
       "169106    1    1\n",
       "169132    0    1\n",
       "169197    0    1\n",
       "169217    0    1\n",
       "169269    0    1\n",
       "169276    0    1\n",
       "169299    0    1\n",
       "169318    0    2\n",
       "169393    3    0\n",
       "169445    1    0\n",
       "169598    1    1\n",
       "169613    0    1\n",
       "169614    0    1\n",
       "169691    0    1\n",
       "169699    1    1\n",
       "169815    0    1\n",
       "169832    0    1\n",
       "169934    1    1\n",
       "169976    0    1\n",
       "\n",
       "[3000 rows x 2 columns]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dingdan2 = dingdan[dingdan['订单状态'] == 1]\n",
    "dingdan2.groupby(['客户ID','优惠类型']).size().unstack().fillna(0).astype(np.int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>优惠类型</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>客户ID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5245</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5254</th>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5286</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5292</th>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5474</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5544</th>\n",
       "      <td>75</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5547</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5552</th>\n",
       "      <td>55</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5560</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5580</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5625</th>\n",
       "      <td>10</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5628</th>\n",
       "      <td>104</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5661</th>\n",
       "      <td>297</td>\n",
       "      <td>126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5690</th>\n",
       "      <td>73</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5699</th>\n",
       "      <td>85</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5701</th>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5723</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5725</th>\n",
       "      <td>56</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5726</th>\n",
       "      <td>87</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5727</th>\n",
       "      <td>24</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5728</th>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5734</th>\n",
       "      <td>45</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5740</th>\n",
       "      <td>12</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5767</th>\n",
       "      <td>8</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5785</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5789</th>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5804</th>\n",
       "      <td>15</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5816</th>\n",
       "      <td>12</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5880</th>\n",
       "      <td>42</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5912</th>\n",
       "      <td>18</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168758</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168792</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168831</th>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168834</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168948</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168976</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168981</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168991</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169031</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169049</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169084</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169106</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169132</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169197</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169217</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169269</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169276</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169299</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169318</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169393</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169445</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169598</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169613</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169614</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169691</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169699</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169815</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169832</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169934</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169976</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3000 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "优惠类型      0    1\n",
       "客户ID            \n",
       "5245      1    0\n",
       "5254      8    1\n",
       "5286      1    1\n",
       "5292      4    2\n",
       "5474      1    1\n",
       "5544     75   16\n",
       "5547      5    4\n",
       "5552     55   96\n",
       "5560      0    1\n",
       "5580      0    2\n",
       "5625     10    2\n",
       "5628    104   52\n",
       "5661    297  126\n",
       "5690     73   95\n",
       "5699     85   17\n",
       "5701      6    1\n",
       "5723      0    1\n",
       "5725     56   31\n",
       "5726     87   96\n",
       "5727     24    8\n",
       "5728      7    8\n",
       "5734     45   43\n",
       "5740     12    7\n",
       "5767      8    5\n",
       "5785      2    1\n",
       "5789      9    6\n",
       "5804     15   12\n",
       "5816     12    3\n",
       "5880     42   28\n",
       "5912     18    4\n",
       "...     ...  ...\n",
       "168758    0    2\n",
       "168792    0    1\n",
       "168831    3    6\n",
       "168834    0    3\n",
       "168948    0    1\n",
       "168976    1    1\n",
       "168981    0    2\n",
       "168991    0    3\n",
       "169031    1    0\n",
       "169049    1    0\n",
       "169084    1    0\n",
       "169106    1    1\n",
       "169132    0    1\n",
       "169197    0    1\n",
       "169217    0    1\n",
       "169269    0    1\n",
       "169276    0    1\n",
       "169299    0    1\n",
       "169318    0    2\n",
       "169393    3    0\n",
       "169445    1    0\n",
       "169598    1    1\n",
       "169613    0    1\n",
       "169614    0    1\n",
       "169691    0    1\n",
       "169699    1    1\n",
       "169815    0    1\n",
       "169832    0    1\n",
       "169934    1    1\n",
       "169976    0    1\n",
       "\n",
       "[3000 rows x 2 columns]"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 也可用透视表实现\n",
    "toushi = dingdan2.pivot_table('订单ID',index='客户ID',columns='优惠类型',aggfunc=len,fill_value=0)\n",
    "toushi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>优惠类型</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>客户ID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5245</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5254</th>\n",
       "      <td>0.888889</td>\n",
       "      <td>0.111111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5286</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5292</th>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5474</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "优惠类型         0         1\n",
       "客户ID                    \n",
       "5245  1.000000  0.000000\n",
       "5254  0.888889  0.111111\n",
       "5286  0.500000  0.500000\n",
       "5292  0.666667  0.333333\n",
       "5474  0.500000  0.500000"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 求出每个用户，优惠订单占总店单的百分比\n",
    "he = toushi.sum(axis=1)#总订单数量\n",
    "he\n",
    "#将计算后的订单比例覆盖如0 ，1列\n",
    "toushi[0] = toushi[0] / he #正常订单的比例\n",
    "toushi[1] = toushi[1] / he #优惠订单的比例\n",
    "toushi.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Int64Index([  5560,   5580,   5723,   6310,   6353,   6380,   7255,   7590,\n",
       "             10822,  10885,\n",
       "            ...\n",
       "            169269, 169276, 169299, 169318, 169613, 169614, 169691, 169815,\n",
       "            169832, 169976],\n",
       "           dtype='int64', name='客户ID', length=1669)"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "youhui = toushi[toushi[1] >= 0.75]\n",
    "youhui.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>优惠类型</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>无价值客户</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>客户ID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5245</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5254</th>\n",
       "      <td>0.888889</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5286</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5292</th>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5474</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5544</th>\n",
       "      <td>0.824176</td>\n",
       "      <td>0.175824</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5547</th>\n",
       "      <td>0.555556</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5552</th>\n",
       "      <td>0.364238</td>\n",
       "      <td>0.635762</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5560</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5580</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5625</th>\n",
       "      <td>0.833333</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5628</th>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5661</th>\n",
       "      <td>0.702128</td>\n",
       "      <td>0.297872</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5690</th>\n",
       "      <td>0.434524</td>\n",
       "      <td>0.565476</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5699</th>\n",
       "      <td>0.833333</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5701</th>\n",
       "      <td>0.857143</td>\n",
       "      <td>0.142857</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5723</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5725</th>\n",
       "      <td>0.643678</td>\n",
       "      <td>0.356322</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5726</th>\n",
       "      <td>0.475410</td>\n",
       "      <td>0.524590</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5727</th>\n",
       "      <td>0.750000</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5728</th>\n",
       "      <td>0.466667</td>\n",
       "      <td>0.533333</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5734</th>\n",
       "      <td>0.511364</td>\n",
       "      <td>0.488636</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5740</th>\n",
       "      <td>0.631579</td>\n",
       "      <td>0.368421</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5767</th>\n",
       "      <td>0.615385</td>\n",
       "      <td>0.384615</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5785</th>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5789</th>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5804</th>\n",
       "      <td>0.555556</td>\n",
       "      <td>0.444444</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5816</th>\n",
       "      <td>0.800000</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5880</th>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5912</th>\n",
       "      <td>0.818182</td>\n",
       "      <td>0.181818</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168758</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168792</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168831</th>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168834</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168948</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168976</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168981</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168991</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169031</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169049</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169084</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169106</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169132</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169197</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169217</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169269</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169276</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169299</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169318</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169393</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169445</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169598</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169613</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169614</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169691</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169699</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169815</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169832</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169934</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169976</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3000 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "优惠类型           0         1  无价值客户\n",
       "客户ID                             \n",
       "5245    1.000000  0.000000    1.0\n",
       "5254    0.888889  0.111111    1.0\n",
       "5286    0.500000  0.500000    1.0\n",
       "5292    0.666667  0.333333    1.0\n",
       "5474    0.500000  0.500000    1.0\n",
       "5544    0.824176  0.175824    1.0\n",
       "5547    0.555556  0.444444    1.0\n",
       "5552    0.364238  0.635762    1.0\n",
       "5560    0.000000  1.000000    0.0\n",
       "5580    0.000000  1.000000    0.0\n",
       "5625    0.833333  0.166667    1.0\n",
       "5628    0.666667  0.333333    1.0\n",
       "5661    0.702128  0.297872    1.0\n",
       "5690    0.434524  0.565476    1.0\n",
       "5699    0.833333  0.166667    1.0\n",
       "5701    0.857143  0.142857    1.0\n",
       "5723    0.000000  1.000000    0.0\n",
       "5725    0.643678  0.356322    1.0\n",
       "5726    0.475410  0.524590    1.0\n",
       "5727    0.750000  0.250000    1.0\n",
       "5728    0.466667  0.533333    1.0\n",
       "5734    0.511364  0.488636    1.0\n",
       "5740    0.631579  0.368421    1.0\n",
       "5767    0.615385  0.384615    1.0\n",
       "5785    0.666667  0.333333    1.0\n",
       "5789    0.600000  0.400000    1.0\n",
       "5804    0.555556  0.444444    1.0\n",
       "5816    0.800000  0.200000    1.0\n",
       "5880    0.600000  0.400000    1.0\n",
       "5912    0.818182  0.181818    1.0\n",
       "...          ...       ...    ...\n",
       "168758  0.000000  1.000000    0.0\n",
       "168792  0.000000  1.000000    0.0\n",
       "168831  0.333333  0.666667    1.0\n",
       "168834  0.000000  1.000000    0.0\n",
       "168948  0.000000  1.000000    0.0\n",
       "168976  0.500000  0.500000    1.0\n",
       "168981  0.000000  1.000000    0.0\n",
       "168991  0.000000  1.000000    0.0\n",
       "169031  1.000000  0.000000    1.0\n",
       "169049  1.000000  0.000000    1.0\n",
       "169084  1.000000  0.000000    1.0\n",
       "169106  0.500000  0.500000    1.0\n",
       "169132  0.000000  1.000000    0.0\n",
       "169197  0.000000  1.000000    0.0\n",
       "169217  0.000000  1.000000    0.0\n",
       "169269  0.000000  1.000000    0.0\n",
       "169276  0.000000  1.000000    0.0\n",
       "169299  0.000000  1.000000    0.0\n",
       "169318  0.000000  1.000000    0.0\n",
       "169393  1.000000  0.000000    1.0\n",
       "169445  1.000000  0.000000    1.0\n",
       "169598  0.500000  0.500000    1.0\n",
       "169613  0.000000  1.000000    0.0\n",
       "169614  0.000000  1.000000    0.0\n",
       "169691  0.000000  1.000000    0.0\n",
       "169699  0.500000  0.500000    1.0\n",
       "169815  0.000000  1.000000    0.0\n",
       "169832  0.000000  1.000000    0.0\n",
       "169934  0.500000  0.500000    1.0\n",
       "169976  0.000000  1.000000    0.0\n",
       "\n",
       "[3000 rows x 3 columns]"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#分离正常客户和无价值客户\n",
    "toushi.loc[youhui.index,'无价值客户'] = 0\n",
    "toushi = toushi.fillna(1)\n",
    "toushi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3000,)"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wujiazhi = toushi['无价值客户'].astype(np.int)\n",
    "wujiazhi.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3000, 6)"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guke.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "      <th>客户类别</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5245</td>\n",
       "      <td>55</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1495339734</td>\n",
       "      <td>206</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5254</td>\n",
       "      <td>69</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1499041945</td>\n",
       "      <td>428</td>\n",
       "      <td>13.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5286</td>\n",
       "      <td>57</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1509936376</td>\n",
       "      <td>280</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5292</td>\n",
       "      <td>184</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1510135868</td>\n",
       "      <td>643</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5474</td>\n",
       "      <td>71</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1481185064</td>\n",
       "      <td>61</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   客户ID  登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)  经验值   订单数  客户类别\n",
       "0  5245    55          1430413266            1495339734  206   1.0     1\n",
       "1  5254    69          1430413266            1499041945  428  13.0     1\n",
       "2  5286    57          1430413266            1509936376  280   1.0     1\n",
       "3  5292   184          1430413266            1510135868  643   5.0     1\n",
       "4  5474    71          1430413266            1481185064   61   2.0     1"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 合并表\n",
    "guke2 = pd.merge(guke,pd.DataFrame(wujiazhi),left_on = '客户ID',right_index=True)\n",
    "guke2 = guke2.rename(columns={'无价值客户':'客户类别'})\n",
    "guke2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 3000 entries, 0 to 2999\n",
      "Data columns (total 7 columns):\n",
      "客户ID                    3000 non-null int64\n",
      "登陆次数                    3000 non-null int64\n",
      "注册时间(距1970-1-1的秒数)      3000 non-null int64\n",
      "本次购买时间(距1970-1-1的秒数)    3000 non-null int64\n",
      "经验值                     3000 non-null int64\n",
      "订单数                     3000 non-null float64\n",
      "客户类别                    3000 non-null int32\n",
      "dtypes: float64(1), int32(1), int64(5)\n",
      "memory usage: 175.8 KB\n"
     ]
    }
   ],
   "source": [
    "guke2.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 客户特征分析\n",
    "分析正常客户和无价值客户的特征和行为差异\n",
    "\n",
    "##### 正常客户和无价值客户比例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0.556333\n",
       "1    0.443667\n",
       "dtype: float64"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = guke2.groupby('客户类别').size()\n",
    "s = pd.Series([s[0]/ s.sum(),s[1]/ s.sum()])\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([<matplotlib.axis.XTick at 0x228f8d376a0>,\n",
       "  <matplotlib.axis.XTick at 0x228f909eef0>],\n",
       " <a list of 2 Text xticklabel objects>)"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAEgCAYAAACpYvj1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAD+RJREFUeJzt3X+sX/Vdx/Hn3b2Wra6ll3rZFpFZp3uvSgz7waasVCTYSLGbWzIXGrstQHBoRgzNSJk6zKrCcO4HgsQ4fswNohKRMLdZhBa8Re7cnIawuLe/lm4ubHTdLS00QIHrH+fc7cvl9t5vy7339N37fCTN/X7O5/Ted9JPX9/P/ZzPOd+BiYkJJEl1vajrAiRJL4xBLknFGeSSVJxBLknFGeSSVNzQQv/A3bv3u01mDg0PL2V8/EDXZUjP49icWyMjywYO1eeMvLihocGuS5Cm5dhcOAa5JBVnkEtScQa5JBVnkEtScQa5JBVnkEtScQa5JBVnkEtScQa5JBW34LfoV3H+Vdu7LuGYcuOWs7ouQTpmOSOXpOIMckkqziCXpOIMckkqziCXpOIMckkqziCXpOIMckkqziCXpOIMckkqziCXpOIMckkqziCXpOIMckkqziCXpOIMckkqziCXpOL6+oSgiNgCbGibmzNzrKfvEuC9wCPtod/IzJzTKiVJhzRrkEfEamA9sAY4Gfhb4A09p7wOeE9m/su8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j79vX6zHxZV7UtBgZ5IRFxHPBp4Js0z1sBeDVwJnBeZn6jo9K0yLVBfuE0XQPAZzLz1AUuaVFxaaWIiDiP5jbnXwd2AB/OzEfavlOBW4E13VWoRW4iM786XUdEHFjoYhYbg7yOp4GrabYd7gWuiojJvgFgf0d1SdBe0GwvyP8BP1gXH6D5QGbNI4O8iMy8DbgtIn4c+FPg5TRPnHumy7qk1gMAmXk/8Iu9He2yi+aRa+QFRcQZNA/t/xTNRaW7M/OJbquS1BVvCCoiIjb1ND+cmTcDL6V5pO29XdQk6ehgkNfxvp7XAwCZuT8zP4T7dKVFzTXyOp5zd1xEnEAzIx9ov0papAzyOpZExCrgIM1Har0deHPbd1NnVUnqnEFex0nAHwIvAV4DbAA+mZmf7bQqSZ1z10oREfGlzDytff0AsJHmlv1hYGNmHuyyPknd8WJnHb3vuBOZ+fXMvAi4C7ixo5okHQUM8joe7Xn9/QufmfkXABHxxgWvSNJRwTXyIqY8a3zrlO5LMtMPmpAWKdfIJak4l1YkqTiDXJKKM8glqTiDXJKK+3/x7tBPaYD1TwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "s.plot.bar()\n",
    "plt.xticks([0,1],['无价值客户','正常客户'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "结论：无价值客户的数量和比例多于正常客户"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "根据 客户类别 分组各列 求平均值  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>客户类别</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>121276.815458</td>\n",
       "      <td>77.547633</td>\n",
       "      <td>1.479904e+09</td>\n",
       "      <td>1.491441e+09</td>\n",
       "      <td>259.021570</td>\n",
       "      <td>2.980827</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>79335.880541</td>\n",
       "      <td>257.391435</td>\n",
       "      <td>1.466927e+09</td>\n",
       "      <td>1.502303e+09</td>\n",
       "      <td>1190.660406</td>\n",
       "      <td>15.485457</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               客户ID        登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)  \\\n",
       "客户类别                                                                        \n",
       "0     121276.815458   77.547633        1.479904e+09          1.491441e+09   \n",
       "1      79335.880541  257.391435        1.466927e+09          1.502303e+09   \n",
       "\n",
       "              经验值        订单数  \n",
       "客户类别                          \n",
       "0      259.021570   2.980827  \n",
       "1     1190.660406  15.485457  "
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gukeMean = guke2.groupby('客户类别').mean()\n",
    "gukeMean"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 年平均登录次数的差异"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "客户类别\n",
       "无价值客户     77.547633\n",
       "正常客户     257.391435\n",
       "Name: 登陆次数, dtype: float64"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "denglu = gukeMean['登陆次数']\n",
    "denglu = denglu.rename(index={0:'无价值客户',1:'正常客户'})\n",
    "denglu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x228f8cc63c8>"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEvCAYAAAC66FFZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAE15JREFUeJzt3XuUXWV5x/HvkCG0gaEZ4uAFiiDqg5W2KSAoQkQqqNzqUrHerdSillpcsgJBUKpQSay6uNYLRBCrXV5AG9oUAbkYhADxUhTxAbmIomhIQ0lIQS7TP/YeOR1nMofJmezsd76ftbJm384+z2Tt8zvvvPvde/cNDw8jSSrDZk0XIEnqHUNdkgpiqEtSQQx1SSqIoS5JBTHUJakg/U2++cqVaxxP2UODg7NYvXpd02VIv8Njs7eGhgb6xltnS70g/f0zmi5BGpPH5sZjqEtSQQx1SSqIoS5JBTHUJakghrokFcRQl6SCGOqSVBBDXZIK0ugVpZI2zFFXHNt0CUU5e/+PNl3CBrOlLkkFMdQlqSATdr9ERD9wLrAzsAVwMtAHnAbcXW92UmZeHRELgEPrZcdk5vLelyxJGk83fepv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JWZv9PtUre2B+vpZ1C19gEGqL4wHqC68AvgVRFxWWbO79jF7h1fDnZtqhEeeCrF66me2boZcDfVbYivBlZRdZ88qa6PzPwF1ZfD+4GHgZOonjb1K6r7hR82KtCvpfqL4Diqlvn5k/5NpA1gS12leDbVbYc/D5wF/BS4DXhxZv7vqG3/MCK+P8Y+1tX7ICIOAM4Bfk7VV34fsCfVl8WhwJKIODwzb6tfewfwr8Bc4FP1Pmb26HeTumaoq/UiYlfg5cCfUo3bv5IqfA8ElkfEL4GbgQuAG4E7unj48bXAgZl5a/0e2wOXZOYwVaBfkpm/qddtRhXkc4Cn1NO7AXv39BeVumCoqwRrgXuBH1K1lHfhiRObj1H1s/cDvwB2BLq5OOslwEc6nv36NGDLiFhA1WonIsjMuZn5OPCyiDiKqr9+UUQsw2fFqgGGulovM+8Czq6HDv4oM18xsi4izgfuyczl9fzx1M/QnGCfS6lPlEbEHOCbwNuA04FDM3OswD6Uqk8dqlE1vwZOmNQvJU2Soa7S7D2qv3wHnujjfh7wbuBF3eyo7hN/NVVQH5eZ/xURpwCXR8Q/AUszc1297Z8DmwM/i4gBYGZ9t8wvRMSzevS7SRNy9ItKc23dJTK37jfvHE9+K/CyzLxnop1ExOHA9VT99C8fGbuemZdT9dc/H7giInaoQ/xUqi+MM4CbgDPr/ZwGXAF8t1e/oLQ+3vtFxYiIPqC/ifvJR0RffRJVapShLkkFsftFkgpiqEtSQQx1SSqIoS5JBTHUJakghrokFeT/ACRf3jnx3tL8AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "denglu.plot.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 正常客户经常登录网站\n",
    "* 无价值客户，登陆次数较少\n",
    "\n",
    "结论：正常客户年均登录257次，无价值客户年均登录77次，正常客户登录次数更多"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 客户会员经验平均值差异"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "客户类别\n",
       "无价值客户     259.021570\n",
       "正常客户     1190.660406\n",
       "Name: 经验值, dtype: float64"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jingyan = gukeMean['经验值']\n",
    "jingyan = jingyan.rename(index={0:'无价值客户',1:'正常客户'})\n",
    "jingyan"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x228f8ee4dd8>"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEvCAYAAABL4wrUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFT9JREFUeJzt3X2QXXV9x/H3hiXYwNps4qIo8iDiFytjo4IoSIAUeQqgo+KzUqjDwzCtHZkEEBVFlEStQwTaWog8VTujQpnQpkojJgYBER+KInyhKCIIssSNJMREINs/zlm5XXeTzd3Nnuxv36+ZnT3nd+6953uTcz/37O/8zjkd/f39SJLKNaXpAiRJW5dBL0mFM+glqXAGvSQVzqCXpMIZ9JJUuM6mCxhKb+8ax3yOke7uafT1rWu6DGlIbp9jq6enq2OodvfoC9fZuV3TJUjDcvscHwa9JBXOoJekwhn0klS4ER2MjYjZwAWZOTsiXglcXC9aD7wvMx+LiBOBU+v2BZm5JCKeA1wGvBj4PXBiZj42tm9BkrQpm92jj4j5wCXA1LppEXBmZh4CXA+cFREzgHnAHOAoYEFETAVOAh7MzEOBa4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ewAjOaHsEODTLffifQGwY0ScTbV3T0SQmbMycyNweEScQdX/vzAiVuK9ezXODHoVKzMfAC6thzH+LDOPGlgWEVcCD2fmbfX8OdT3NN3May6lPhgbETOBbwEnAouA4zJzqBA/jqqPHqrRPI8B57b1pqQ2GPSaLA4c1P++G8/2mb8cOB14/UheqO5jfwtVeJ+Vmf8TERcAyyLis8DSzFxXP/avgO2BX0VEFzC1vorolyPiJWP03qRNctSNJotb6u6UWXU/fOt493uBwzPz4c29SEScAHyPqt//yIGx9Zm5jKr//xXATRGxWx3sF1J9iXwBuBO4uH6di4CbgB+O1RuUhuO1blS8iOgAOpu4Hn9EdNQHaqXGGPSSVDi7biSpcAa9JBXOoJekwhn0klQ4g16SCmfQS1Lh/g/UQIs7jrxy1AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "jingyan.plot.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 正常客户：购买很多原价商品并参与评价，经验值高\n",
    "* 无价值客户：购买商品较少，多为优惠商品，很少评价\n",
    "\n",
    "结论：正常客户经验值更高"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 客户平均订单数的差异"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "客户类别\n",
       "无价值客户     2.980827\n",
       "正常客户     15.485457\n",
       "Name: 订单数, dtype: float64"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dingdanshu = gukeMean['订单数']\n",
    "dingdanshu = dingdanshu.rename(index={0:'无价值客户',1:'正常客户'})\n",
    "dingdanshu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x228f8f234a8>"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAEvCAYAAACKZEB4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAEytJREFUeJzt3X2QXXV9x/H3JmtoQ5a64FVRhKCOX1SmjYqKIgERkQdBR0Trc0stlTqtHRkSUBSrKODToEBrCwpitY4SZKBNlQJGwYCK1jJi+Wqj+IAgC64SiAaU9I9zVm7Xfbg5ubvn/rLv10xmz9Oe+92Zcz/nl9/5nXOGtmzZgiSpLIvaLkCStPUMb0kqkOEtSQUyvCWpQIa3JBXI8JakAg33slFErAROy8yVEbEzcD7QARYDr8nMDTP9/tjYRscj9tHo6FLGxze1XYY0JY/P/ul0RoamWzdryzsiVgHnAEvqRacBn8rM/YFTgSf3o0j1bnh4cdslSNPy+JwfvXSbbACO7po/CNgjIq4CXg5cNReFSZKmN2u3SWauiYjlXYuWA/dm5vMi4m3AycApM+1jdHSpZ+M+63RG2i5BmpbH59zrqc97kvuANfX0pcAZs/2C/V/91emMMDa2se0ypCl5fPbPTCfBJqNN1gOH1NMHAjc22IckaRs0aXn/NfCRiPgrYBx4XX9LkiTNZmg+niroUMH+8r+lGmQen/2zTUMFJUmDx/CWpAI16fOW1II3Xr2q7RK2G+ce9N62S9hmtrwlqUCGtyQVyPCWpAIZ3pJUIMNbkgpkeEtSgQxvSSqQ4S1JBTK8JalAhrckFcjwlqQCGd6SVCDDW5IKZHhLUoEMb0kqkOEtSQXqKbwjYmVEfHnSssMj4rq5KUuSNJNZ36QTEauAVwObupYtA04D7pu70iRJ0+ml5b0BOHrSsncD5/a/HElSL2ZteWfmmohYPjEfEfsCOwFXAX/Zy4eMji5leHhx0x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5gPAwRHxRqr+9DMj4hp8j6haYHirGJl5C3BuPSTvO5l56MS6iLgQuDUzr6/nT6Z+x+Is+1xLfcEyInYBrgJeB3wIODIzpwrmI6n6vKEaxXIH8NZGf5TUkOGtUj17Un/27jzYB/1E4HjgWb3sqO6zfglVIK/OzP+OiNOAKyPifcDazNxUb/s84CHAjyNiBFhSP9nxkxHx2D79bdKsHG2iUq2vuzJW1P3a3eOxvwscnJm3zraTiDgG+CpVP/oLJsZ+Z+aVVP3pTwaujojd67A+nerE8GHgRuDsej9nAVcD3+zXHyjNxGebqDgRMQQMt/Es84gYqi9mSq0yvCWpQHabSFKBDG9JKpDhLUkFMrwlqUCGtyQVyPCWpAL9H67AkLCYx/HMAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "dingdanshu.plot.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 正常客户：购买次数较多\n",
    "* 无价值客户：购买次数较少\n",
    "\n",
    "结论： 正常客户平均订单数更高"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 注册时间和购买时间差异\n",
    "* 注册时间和购买时间差异\n",
    "* 注册后当天购买的人"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "      <th>客户类别</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5245</td>\n",
       "      <td>55</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1495339734</td>\n",
       "      <td>206</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5254</td>\n",
       "      <td>69</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1499041945</td>\n",
       "      <td>428</td>\n",
       "      <td>13.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5286</td>\n",
       "      <td>57</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1509936376</td>\n",
       "      <td>280</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5292</td>\n",
       "      <td>184</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1510135868</td>\n",
       "      <td>643</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5474</td>\n",
       "      <td>71</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1481185064</td>\n",
       "      <td>61</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   客户ID  登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)  经验值   订单数  客户类别\n",
       "0  5245    55          1430413266            1495339734  206   1.0     1\n",
       "1  5254    69          1430413266            1499041945  428  13.0     1\n",
       "2  5286    57          1430413266            1509936376  280   1.0     1\n",
       "3  5292   184          1430413266            1510135868  643   5.0     1\n",
       "4  5474    71          1430413266            1481185064   61   2.0     1"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guke2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "      <th>客户类别</th>\n",
       "      <th>相隔秒数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5245</td>\n",
       "      <td>55</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1495339734</td>\n",
       "      <td>206</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>64926468</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5254</td>\n",
       "      <td>69</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1499041945</td>\n",
       "      <td>428</td>\n",
       "      <td>13.0</td>\n",
       "      <td>1</td>\n",
       "      <td>68628679</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5286</td>\n",
       "      <td>57</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1509936376</td>\n",
       "      <td>280</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>79523110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5292</td>\n",
       "      <td>184</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1510135868</td>\n",
       "      <td>643</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1</td>\n",
       "      <td>79722602</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5474</td>\n",
       "      <td>71</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1481185064</td>\n",
       "      <td>61</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1</td>\n",
       "      <td>50771798</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   客户ID  登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)  经验值   订单数  客户类别  \\\n",
       "0  5245    55          1430413266            1495339734  206   1.0     1   \n",
       "1  5254    69          1430413266            1499041945  428  13.0     1   \n",
       "2  5286    57          1430413266            1509936376  280   1.0     1   \n",
       "3  5292   184          1430413266            1510135868  643   5.0     1   \n",
       "4  5474    71          1430413266            1481185064   61   2.0     1   \n",
       "\n",
       "       相隔秒数  \n",
       "0  64926468  \n",
       "1  68628679  \n",
       "2  79523110  \n",
       "3  79722602  \n",
       "4  50771798  "
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guke2['相隔秒数'] = guke2['本次购买时间(距1970-1-1的秒数)'] - guke2['注册时间(距1970-1-1的秒数)']\n",
    "guke2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "客户类别\n",
       "0    133.528688\n",
       "1    409.442822\n",
       "Name: 相隔秒数, dtype: float64"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "miaoshu = guke2.groupby('客户类别')['相隔秒数'].mean()/ (24 * 3600)\n",
    "miaoshu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([<matplotlib.axis.XTick at 0x228f8006898>,\n",
       "  <matplotlib.axis.XTick at 0x228f8006208>],\n",
       " <a list of 2 Text xticklabel objects>)"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEvCAYAAAC66FFZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFu5JREFUeJzt3X+U3XV95/HnkCHsBgYzSYdqtRFK7Rtats0KSkWIyAoiELYHa2trq2Jb/MF26SknEAqVKlQS1/aAylaUCMZt91QFNbRZBIRgUBDRuljEN1RU1IoO2UlJyBKBTP/4fkdu0zszN5M7+eb7mefjnJz53s/33u99T873vu5nPt8fn4Hx8XEkSWXYp+kCJEn9Y6hLUkEMdUkqiKEuSQUx1CWpIIa6JBVksMk3Hx3d4vmUfTQ8vICxsW1NlyH9O+6b/TUyMjQw2Tp76gUZHJzXdAlSV+6be46hLkkFMdQlqSCGuiQVxFCXpIIY6pJUEENdkgpiqEtSQQx1SSpIo1eUSto9Z996XtMlFOXKE97ddAm7zZ66JBWkp556RCwA7gNeBfwIuBYYAkaBMzPz8Yg4CXgHsANYm5lXzUrFkqRJ9dpTvwR4Vr18PnBDZr4c+CpwVkQMAlcApwHHA2+JiIP6XKskaRrThnpEHAUsAu6tm5YB6+vl9cBxwKHA9zJzU2Y+CdwO/Gr/y5UkTWXK4Ze6B74a+E3gE3XzYmBzv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frntyfeV9oTDHWV5D3Ae4H/DPxMR/sKqlCfcEBm/rthl7q3PVwv/wxVbx9giOoL4zGqC78Afi0ibs7MFR2bOLLjy8GhTTXCHU+leC3VnK37AA9T3Yb4dmAT1fDJLg19ZOY/U305/AmwHbiYarapH1LdL/z0nQL9C1R/EZxP1TO/dsa/ibQb7KmrFD9PddvhjwLvB74DPAi8NDP//07P/dmI+GqXbWyrt0FEnAh8CPge1Vj5o8CLqb4slgPrIuI1mflg/dqHgP8NLAU+UG9jfp9+N6lnhrpaLyKOAF4J/ArVefu3UYXvScBdEfED4D5gLfAl4KEeJj/+AnBSZj5Qv8fzgBszc5wq0G/MzB/X6/ahCvLFwE/Vyy8EjunrLyr1wFBXCbYCjwD/SNVTPoxnDmw+TTXOPgj8M3Aw0MvFWS8D3tUx9+uzgf0jYiVVr52IIDOXZuYO4BURcTbVeP3qiNiIc8WqAYa6Wi8zvw1cWZ86+PXMPHliXURcC3w/M++qH19APYfmNNtcT32gNCIWA58F3gBcASzPzG6BvZxqTB2qs2p+BFw4o19KmiFDXaU5Zqfx8iU8M8Z9OPBW4CW9bKgeEz+DKqjPz8z/GxGXArdExP8A1mfmtvq5/wXYF/huRAwB8+u7Zf51RPxcn343aVqe/aLSfKEeEllaj5t3nk/+APCKzPz+dBuJiNcAX6Qap3/lxLnrmXkL1Xj9LwG3RsSSOsQvo/rCeC9wL/C+ejuXA7cCX+nXLyhNxXu/qBgRMQAMNnE/+YgYqA+iSo0y1CWpIA6/SFJBDHVJKoihLkkFMdQlqSCGuiQVxFCXpIL8Kzv2EJBgR4RHAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "miaoshu.plot.bar()\n",
    "plt.xticks([0,1],['无价值客户','正常客户'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "结论：正常客户购买间隔的秒数的更长"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "客户类别\n",
       "0    0.001545\n",
       "1    0.004739\n",
       "Name: 相隔秒数, dtype: float64"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 注册于本次购买相距时间（天）\n",
    "miaoshu = miaoshu / 86400\n",
    "miaoshu"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 注册当天后购买的人"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>客户ID</th>\n",
       "      <th>登陆次数</th>\n",
       "      <th>注册时间(距1970-1-1的秒数)</th>\n",
       "      <th>本次购买时间(距1970-1-1的秒数)</th>\n",
       "      <th>经验值</th>\n",
       "      <th>订单数</th>\n",
       "      <th>客户类别</th>\n",
       "      <th>相隔秒数</th>\n",
       "      <th>是否当天</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5245</td>\n",
       "      <td>55</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1495339734</td>\n",
       "      <td>206</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>64926468</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5254</td>\n",
       "      <td>69</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1499041945</td>\n",
       "      <td>428</td>\n",
       "      <td>13.0</td>\n",
       "      <td>1</td>\n",
       "      <td>68628679</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5286</td>\n",
       "      <td>57</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1509936376</td>\n",
       "      <td>280</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>79523110</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5292</td>\n",
       "      <td>184</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1510135868</td>\n",
       "      <td>643</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1</td>\n",
       "      <td>79722602</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5474</td>\n",
       "      <td>71</td>\n",
       "      <td>1430413266</td>\n",
       "      <td>1481185064</td>\n",
       "      <td>61</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1</td>\n",
       "      <td>50771798</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   客户ID  登陆次数  注册时间(距1970-1-1的秒数)  本次购买时间(距1970-1-1的秒数)  经验值   订单数  客户类别  \\\n",
       "0  5245    55          1430413266            1495339734  206   1.0     1   \n",
       "1  5254    69          1430413266            1499041945  428  13.0     1   \n",
       "2  5286    57          1430413266            1509936376  280   1.0     1   \n",
       "3  5292   184          1430413266            1510135868  643   5.0     1   \n",
       "4  5474    71          1430413266            1481185064   61   2.0     1   \n",
       "\n",
       "       相隔秒数  是否当天  \n",
       "0  64926468     0  \n",
       "1  68628679     0  \n",
       "2  79523110     0  \n",
       "3  79722602     0  \n",
       "4  50771798     0  "
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 注册后当天购买的人\n",
    "dangtian = guke2['注册时间(距1970-1-1的秒数)'] + 86400 >= guke2['本次购买时间(距1970-1-1的秒数)']\n",
    "dangtian\n",
    "def d(x):\n",
    "    return np.where(x,1,0)\n",
    "dt = dangtian.map(d)\n",
    "guke2['是否当天'] = dt\n",
    "guke2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "客户类别\n",
       "0    0.183343\n",
       "1    0.007513\n",
       "Name: 是否当天, dtype: float64"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dtian = guke2.groupby(['客户类别'])['是否当天'].mean()\n",
    "dtian"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([<matplotlib.axis.XTick at 0x228f87ea080>,\n",
       "  <matplotlib.axis.XTick at 0x228f880c860>],\n",
       " <a list of 2 Text xticklabel objects>)"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEvCAYAAACpPxGtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGPxJREFUeJzt3X20XXV95/H3MddkJngDAY+FIinB6lemdgbkwSeSakZiAw1TXbUOdmAELGsozqxZsJRYsGlrpwZHHQQVB0lEOnasCkxhJhAeEiBBoyDjWCj5BgsFq1IvcCEJGTDCmT/2vnJ6m5u7ITd3Z87v/Vor6569f3vv893r7HzOPr/91On1ekiSyvCStguQJE0fQ1+SCmLoS1JBDH1JKoihL0kFMfQlqSBDbRewKyMjWz2fdArNnTub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sW/8B6lCf8zLMvMfdevUe+tz69e/SPVrAWCY6gtlC9VFcQC/GRE3ZeYH+xZxVN+Xh12raoUbnkrxr6meF/wS4GGqW0zfBjxG1T3zgrpWMvNHVF8evw88AyynelLZ31PdL/6kcYH/DapfFOdR7dlf8aLXRNoN7umrFL9MdUvpPwM+AzwE3A+8JTP/77hpD4mI7+5kGdvrZRARxwNfAP6Oqq/+UeBYqi+TpcC1EfHuzLy/nvcB4L8DRwCfr5cxc4rWTWrM0NfAi4jXAe8A/gXVNQvrqMJ5MbAxIn4M3AtcCdwJPNDg4dzfABZn5ub6PV4J3JCZParAvyEzf1q3vYQq6A8AXl6/fj3w5ildUakBQ18l2AY8AtxDtaf9Wp4/8PosVT//EPAj4FCgyYVrvwb8ad9zhw8E9omIZVR7/UQEmXlEZj4HvD0izqY6XnBhRKzH5xSrBYa+Bl5m/i3w2frUyL/OzF8fa4uIK4AfZubGevjD1M9wnWSZq6kP5EbEAcAtwL8FPg0szcydBfpSqj59qM4K+glw/otaKelFMvRVmjeP66+fx/N97IcDZwFvarKguk/+XVRBfl5m/p+I+BPg5oj4z8DqzNxeT/svgZcCP4iIYWBmfafTL0fEYVO0btKkPHtHpflG3eVyRN1v338+/Wbg7Zn5w8kWEhHvBr5FdZzgHWPn7mfmzVTHC34FWBsR8+qQ/xjVF8rFwPeAS+rlXASsBe6eqhWUdsV776gYEdEBhtp4lkBEdOqDvFKrDH1JKojdO5JUEENfkgpi6EtSQQx9SSqIoS9JBTH0Jakg/w+jyih02gjBtAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "dtian.plot.bar()\n",
    "plt.xticks([0,1],['无价值客户','正常客户'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "结论：\n",
    "* 无价值客户有18.3%在注册当天下单购买商品\n",
    "* 正常用户有0.7%在当天下单购买商品\n",
    "\n",
    "正常客户一般不在注册当天后购物"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "分析结束"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 研究结论\n",
    "## 研究总结\n",
    "-----\n",
    "\n",
    "正常客户：\n",
    "* 占所有客户的44.3%\n",
    "* 年平均登陆257次\n",
    "* 0.75%的客户在注册当天购买\n",
    "* 注册时间与本次购买时间相隔409天\n",
    "* 会员经验平均值1190分\n",
    "* 平均订单15单\n",
    "\n",
    "\n",
    "无价值客户：\n",
    "* 占所有客户的55.6%\n",
    "* 年平均登陆77次\n",
    "* 18.3%的客户在注册当天购买\n",
    "* 注册时间与本次购买时间相隔133天\n",
    "* 会员经验平均值259分\n",
    "* 平均订单2单\n",
    "---\n",
    "### 正常客户和无价值客户的总体差异：\n",
    "\n",
    "相对于正常客户，无价值客户：\n",
    "\n",
    "* 登陆次数**更少**\n",
    "* 会员经验**更少**\n",
    "* 购买订单数**更少**\n",
    "* 注册和购物时间将**更短**\n",
    "* 注册后当天购买的比例**更高**\n",
    "\n",
    "---\n",
    "\n",
    "### 商品优惠分析\n",
    "\n",
    "* 整体看优惠商品的优惠幅度不大，主要集中在5元以下，\n",
    "* 最受欢迎的优惠商品主要是：柑橘、藕、青椒等常见蔬菜水果\n",
    "\n",
    "---\n",
    "\n",
    "### 相关建议\n",
    "\n",
    "下订单“稳准快”的无价值客户，不会在正价商品上过多停留，不会花时间去关注除优惠商品以外的其他商品。\n",
    "\n",
    "为了节省优惠营销费用、提高盈利，给出以下建议：\n",
    "\n",
    "* 关联推广\n",
    "    * 在优惠商品处增加原价商品广告，引导客户顺便购买\n",
    "* 打包销售\n",
    "    * 将优惠商品与原价商品打包组合销售\n",
    "* 给予推广部门激励：\n",
    "    * 如果本月将无价值客户的比例从55.6%降至25%，每人奖励一万元"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
